package process

import (
	"fmt"
	"go_code/chatroom/client/model"
	"go_code/chatroom/common/message"
)

//客户端维护到map
var onlineUsers map[int]*message.User = make(map[int]*message.User, 10)

var CurUser model.CurUser //在用户登陆成功后对其初始化

//在客户端显示当前在线的用户
func outputOnlineUser() {
	//遍历
	fmt.Println("当前在线用户列表：")
	for id, _ := range onlineUsers{
		fmt.Println("用户id：\t", id)
	}
}


//处理返回信息
func updateUserStatus(notifyUserStatusMes *message.NotifyUserStatusMes) {

	user := onlineUsers[notifyUserStatusMes.UserId]
	if user == nil {
		user = &message.User{
			UserId: notifyUserStatusMes.UserId,
		}
	}

	user.UserStatus = notifyUserStatusMes.Status
	onlineUsers[notifyUserStatusMes.UserId] = user
	outputOnlineUser()
}

